<template>
	<mescroll-uni :height="height + 'px'" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" :down="downOption">
		<block v-for="(item, index) in noticeList" v-if="!item.is_delete" :key="item.type_id"><chat-session-item ref="chatSessionItem" @handle="toNoticePage" :item="item" :index="index" type="officialNotice"></chat-session-item></block>
	</mescroll-uni>
</template>

<script>
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
import chatSessionItem from '@/components/chat/chat-session-item.vue';
import { mapState } from 'vuex';
import { getNoticeList } from '@/store/dispatches.js';
export default {
	mixins: [MescrollMixin], // 使用mixin
	components: { chatSessionItem },
	props: {
		height: {
			default: null,
			type: [String, Number]
		}
	},
	data() {
		return {
			upOption: {
				auto: false
			},
			downOption: {
				auto: false
			}
		};
	},
	computed: {
		...mapState({
			noticeList: state => state.iMessage.noticeList
		})
	},
	methods: {
		refreshData() {
			this.mescroll && this.mescroll.resetUpScroll(false);
		},
		mescrollInit(mescroll) {
			this.mescroll = mescroll;
			this.mescroll.resetUpScroll(false);
		},
		upCallback(mescroll) {
			getNoticeList(() => {
				this.mescroll.endSuccess(this.noticeList.length, false);
			});
		},
		toNoticePage(data) {
			this.navigateTo({
				url: '/pageSupport/notice/index?id=' + data.key
			});
		}
	}
};
</script>

<style></style>
